package model.characters.weapons;

import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;

import model.ComponentTypeEnum;
import model.LayerEnum;
import model.ModelComponent;

public class Pistol38 implements Weapon, ModelComponent{
	
	private Rectangle region;
	private List<Handable> actions;
	private ComponentTypeEnum type;
	
	int clip;
	int load = 8;
	int bullets = 80;
	int shootInterval = 30;
	int shootFrame;
	boolean using;
	
	int loadInterval = 400;
	int currentLoad;
	
	public Pistol38() {
		actions = new ArrayList<Handable>();
		region = new Rectangle(28, 7);
		type = ComponentTypeEnum.WEAPON_PISTOL38;
	}

	@Override
	public Rectangle getRegion() {
		return region;
	}

	@Override
	public void use(Integer direction) {
		if(!using){
			actions.add(new Pistol38Shot(new Point(region.x+(direction>0?region.width:-5),region.y),direction));
			using = true;
		}
		else{
			if(shootFrame++>10){
				using = false;
				shootFrame = 0;
			}
		}
	}
	
	@Override
	public void reload(){
		clip = 0;
		currentLoad=0;
	}

	@Override
	public List<Handable> getActions() {
		return actions;
	}

	@Override
	public void removeAction(Handable action) {
		actions.remove(action);	
	}
	
	@Override
	public LayerEnum getLayer() {
		return LayerEnum.LAYER_1;
	}

	@Override
	public boolean isUsing() {
		return using;
	}

	@Override
	public ComponentTypeEnum getType() {
		return type;
	}

}